<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import="pojo.*,service.*,base.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    if(session.getAttribute("name")!=null){
	String date = request.getParameter("date").trim();
	
	int tabletype=Integer.parseInt(request.getParameter("tabletype").trim());
	
    int tablearea=Integer.parseInt(request.getParameter("tablearea").trim());
    
    int ctype =Integer.parseInt(request.getParameter("ctype").trim().trim());

	TableService ds = new TableService();
	
	int r = ds.getTotalTable(tablearea,tabletype);
	
	int m = ds.getTableNum(date,tablearea,tabletype,ctype);
	
	if(m<r){
	
		out.print("订座成功！您现在可以去点菜！！！如果页面1秒后未自动跳转，请点击<a href='../../website/index.jsp'>主页</a> ");
		session.setAttribute("date",date);
	    session.setAttribute("tablearea",tabletype);
	    session.setAttribute("tabletype",tablearea);
	    session.setAttribute("type",ctype);
	    response.setHeader("refresh","1;URL=../../website/index.jsp") ;
	}
		else{
	out.print("你所选的时段餐桌已无剩余！！请重新选择！！！！！！！ 如果页面1秒后未自动跳转，请点击<a href='../../website/index.jsp'>主页</a>");
	response.setHeader("refresh","1;URL=../../website/index.jsp") ;
	}
	}
	else response.sendRedirect("../../website/login.jsp");
%>
</body>
</html>
